package com.staryea.hive;

import java.sql.Connection;
import java.sql.DriverManager;


public class HiveConnectFactory {
    //用户名
    private static String user = "";

    //密码
    private static String password = "";

    //连接url
    private static String url = "";

    public static Connection getConnection() {
        try {
            return DriverManager.getConnection(url,user,password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void setDriverClassName(String driverClassName) throws ClassNotFoundException {
        Class.forName(driverClassName);
    }

    public static void setUrl(String url) {
        HiveConnectFactory.url = url;
    }

    public static void setUser(String user) {
        HiveConnectFactory.user = user;
    }

    public static void setPassword(String password) {
        if (password == null) {
            return;
        }
        HiveConnectFactory.password = password;
    }
}
